Learning Objectives

After completing this lesson, you’ll be able to:

Instructions

In this lesson, you will:

Resources

What is Group By?

Group By parameters allow records to be processed in groups by a single FME transformer.

FME transformers perform transformations on either one record at a time or a whole set of records at once.

Creating Groups

A group is a defined set of records processed by a transformer. By default, group-based transformers treat all the records they receive as a single group.

However, such transformers also have a Group By parameter. This parameter allows the user to define multiple groups based on an attribute's value.

Note

To illustrate groups, let's consider calculating the mean age of FME users. The default group for the calculation includes all FME users.

But you could instead divide everyone by their nationality and calculate the average age per country.

This is the same as having a nationality attribute in a dataset and selecting that in an FME Group By parameter.

Here, a Dissolver transformer is used to dissolve (merge) several polygon records. The selected Group By attribute is ViewDescription. Additionally, you can set Complete Groups to When All Features Received, which makes the Dissolver a blocking transformer, or to When Group Changes (Advanced). The latter option should only be used when your data is sorted by the value(s) of the grouping attribute(s). It can offer a performance boost if your data is already sorted or if you are processing many records.

Setting a Group By parameter

FME creates a series of groups for overlaying, where the records in each group share the same value for the ViewDescription attribute. The practical outcome is that polygon dissolving takes place only where line records share the same description:

Example of results of using a Dissolver on geometry

Complete Groups

When grouping records, the transformer can handle the group in two different ways. The first way is to hold all of the records until all of the records have come through the transformer; this is referred to as blocking. This blocking occurs when Complete Groups is set to When All Features Received.

The other way is to pre-sort your data into groups using a transformer like the Sorter. Then, once your data is grouped, set Complete Groups to When Group Changes (Advanced). This mode will push the records through the transformer after each group, which will help speed up performance. Only use this option when your data is pre-sorted.

Exercise

Sven continues to work with the city park data. He's been asked to add the average size of parks in each neighborhood. To do this, he can use the Group By parameter with an existing workspace.

1) Open Starting Workspace

Starting workspace

2) View AverageParkArea Values

AverageParkArea in Table View

3) Set Group By in the StatisticsCalculator

Now we'd like to change the workspace to calculate the park area by neighborhood.

Group By Neighborhood

He clicks OK.

4) Run the Workspace

Summary port

5) Add Another Neighborhood

We decide to include the Fairview neighborhood in the written data as well.

Summary port

Leave Us Feedback on This Lesson